<!--
  ~ This program is part of the OpenLMIS logistics management information system platform software.
  ~ Copyright © 2013 VillageReach
  ~
  ~ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  ~  
  ~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
  ~ You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
  -->

<div ng-hide="roles" openlmis-message="msg.loading"></div>
<div ng-show="roles">
  <h2>
    <span id="rolesHeader" openlmis-message="roles.header"></span>
    <a id="role-add-new" ng-href="#/create" class="pull-right btn btn-primary"
       openlmis-message="button.add.new"></a>
  </h2>

  <div class="alert alert-success" id="saveSuccessMsgDiv" ng-bind="message" ng-show="message"/>
  <table class="table table-striped table-bordered">
    <thead>
    <tr class="gradient-header">
      <th id="nameHeader" openlmis-message="header.name"></th>
      <th id="descriptionHeader" openlmis-message="label.description"></th>
      <th id="rightsHeader" openlmis-message="header.rights"></th>
    </tr>
    </thead>
    <tbody>
    <tr ng-repeat="role in roles">
      <td><a id="role{{$index}}" ng-href="#/edit/{{role.id}}">{{role.name}}</a></td>
      <td id="description{{$index}}" ng-bind="role.description"></td>
      <td>
        <div ng-repeat="right in role.rights">
          <div id="right{{$parent.$index}}{{$index}}">
            <span ng-if="right.displayNameKey != null" openlmis-message="right.displayNameKey"></span>
            <span ng-if="right.type === 'REPORTING' && right.name !== 'MANAGE_REPORT'">
              <span openlmis-message="label.reporting.right.view"></span>
              <span ng-bind="right.name"></span>
            </span>
          </div>
        </div>
      </td>
    </tr>
    </tbody>
  </table>
</div>
